<script setup>
import { reactive } from 'vue'

const teamMembers = reactive([{
  name: "徐伟强",
  role: "项目经理 & 后端开发",
  tasks: [
    "项目整体架构设计",
    "协调团队开发工作",
    "RESTful API开发",
    "数据库设计"
  ]
},
  {
    name: "杨伦",
    role: "前端开发工程师",
    tasks: [
      "UI/UX设计实现",
      "Vue框架开发",
      "状态管理维护",
      "性能优化"
    ]
  },
  {
    name: "周瑞麟",
    role: " 后端开发",
    tasks: [
      "图像识别模型开发",
      "NLP算法优化",
      "数据处理与清洗",
      "模型部署"
    ]
  },])

const getInitials = (name) => name.slice(0, 2)
const colors = ['#3498db', '#e74c3c', '#2ecc71', '#f1c40f']
const getColor = (index) => colors[index % colors.length]
</script>

<template>
  <section class="team">
    <h2>团队分工</h2>

    <div class="grid">
      <div v-for="(member, index) in teamMembers" :key="index" class="member">
        <div
          class="avatar"
          :style="{ backgroundColor: getColor(index) }"
        >
          {{ getInitials(member.name) }}
        </div>

        <div class="info">
          <h3>{{ member.name }}</h3>
          <p class="role">{{ member.role }}</p>
        </div>

        <ul class="tasks">
          <li v-for="(task, taskIndex) in member.tasks" :key="taskIndex">
            {{ task }}
          </li>
        </ul>
      </div>
    </div>
  </section>
</template>

<style scoped>
.team {
  background: #fff;
  padding: 2rem;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 2rem;
  margin-top: 1.5rem;
}

.member {
  padding: 1.5rem;
  border-radius: 8px;
  background: #f8f9fa;
  transition: transform 0.2s;
}

.member:hover {
  transform: translateY(-5px);
}

.avatar {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: bold;
  margin: 0 auto 1rem;
}

.info {
  text-align: center;
  margin-bottom: 1rem;
}

.info h3 {
  color: #2c3e50;
  margin-bottom: 0.25rem;
}

.role {
  color: #7f8c8d;
  font-size: 0.9rem;
}

.tasks {
  list-style: none;
  padding: 0;
  border-top: 1px solid #eee;
  padding-top: 1rem;
}

.tasks li {
  padding: 0.5rem;
  color: #555;
  position: relative;
  padding-left: 1.2rem;
}

.tasks li::before {
  content: "•";
  color: #3498db;
  position: absolute;
  left: 0;
}
</style>
